package com.bqjr.queue.listener;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.bqjr.bean.Foo;

@Component
@RabbitListener(containerFactory="firstContainerFactory")
public class HelloListener {
    public HelloListener(){
        System.out.println("HelloListener init");
    }
    
    @RabbitListener(queues = "cqy.queue.str")
    public void strLisMuti(String hello) {
        System.out.println("Receiver muti  : " + hello);
    }
    
    // 与MQ中的队列名保持一致
    @RabbitListener(queues = "cqy.queue.str")
    public void strLis(String hello) {
        System.out.println("Receiver1  : " + hello);
    }
    
    @RabbitListener(queues = "cqy.queue.str")
    public void strLis2(String hello) {
        System.out.println("Receiver2  : " + hello);
    }
    
    @RabbitListener(queues = "cqy.queue.obj")
    public void objLis(Foo obj) {
        System.out.println("recieve: " + obj.getName());
    }
    
    @RabbitListener(queues = "cqy.queue.topic")
    public void topicQuLis(String str) {
        System.out.println("recieve: " + str);
    }
    
    @RabbitListener(queues = "cqy.queue.fanoutA")
    public void fanoutQuLisA(String str) {
        System.out.println("recieve A: " + str);
    }
    @RabbitListener(queues = "cqy.queue.fanoutB")
    public void fanoutQuLisB(String str) {
        System.out.println("recieve B: " + str);
    }
}
